{{include file="header.html"}}
<body class="body_bg {{if $smarty.get.act == 'student_register'}}bg1{{/if}}">
	<div class="container">
		<!-- 切换内容整体 -->
		<div class="tab_main">
			<p><img src="{{$smarty.const.__APP__}}images/{{if $smarty.get.act == 'student_register'}}logo1.png{{elseif $smarty.get.act == 'teacher_register'}}logo.png{{/if}}" alt="" class="logo logo1"></p>
			<!-- 切换导航 -->
			<div class="process">
				<div class="tab select {{if $smarty.get.act == 'student_register'}}tab_s{{/if}}">
					<div class="home">
						<svg class="icon" aria-hidden="true">
							<use xlink:href="{{if $smarty.get.act == 'student_register'}}#icon-xuesheng{{elseif $smarty.get.act == 'teacher_register'}}#icon-laoshi{{/if}}"></use>
						</svg>
					</div>{{if $smarty.get.act == 'student_register'}}创新创业学生管理系统{{elseif $smarty.get.act == 'teacher_register'}}创新创业教师管理系统{{/if}}
					<div class="tran"></div>
				</div>
				<div class="clear"></div>
			</div>
			<!-- 内容列表 -->
			<div class="cont">
				<form action="index.php?app=index" name="myform" method="post" class="ajaxSubmit" onsubmit="return false">
					<table>
						<tr>
							<td>真实姓名：</td>
							<td><input type="text" name="username" placeholder="请输入真实姓名" tab="username"></td>
							<td class="info"></td>
						</tr>
						<tr>
							<td>邮件：</td>
							<td><input type="text" name="email" placeholder="请输入邮件" tab="email"></td>
							<td class="info"></td>
						</tr>
						<tr>
							<td>密码：</td>
							<td><input type="password" name="password" placeholder="请输入密码" tab="password"></td>
							<td class="info"></td>
						</tr>
						<tr>
							<td>确认密码：</td>
							<td><input type="password" name="s_password" placeholder="请再输入一次密码" tab="s_password"></td>
							<td class="info"></td>
						</tr>
						<tr>
							<td>验证码：</td>
							<td>
								<input class="verify" name="verify" type="text" placeholder="验证码">
								<img src='{{"index.php?app=Functions&act=getVerifyCode"|URL}}' onclick="this.src=this.src+'?'" style="cursor:pointer" class="change_verify">
							</td>
							<td class="info"></td>
						</tr>
						<tr>
							<td>性别：</td>
							<td>
								<label for="man"><input type="radio" name="sex" checked="" id="man" value="0">男</label>
								<label for="woman"><input type="radio" name="sex" id="woman" value="1">女</label>
							</td>
							<td class="info"></td>
						</tr>
						<tr>
						<tr>
							<td></td>
							<td>
								<button id="next" onClick="login();">完成</button>
							</td>
						</tr>
					</table>
					<input type="hidden" value="{{if $smarty.get.act == 'student_register'}}0{{elseif $smarty.get.act == 'teacher_register'}}1{{/if}}" name="type">
				</form>
			</div>
		</div>
	</div>
	</body>
	<script>
	$(function(){
		// 使输入整体居中
		window.onload = function() {doted(); setHeight("body_bg","container",0);};
		window.onresize = function() {doted(); setHeight("body_bg","container",0);};
	})

	//所有验证
	$("input").blur(function(){
		verify(this);
	});

	//验证
	var verify = function(obj){
		var tab = $(obj).attr('tab');//获取标志
		var val = $(obj).val();
		//用户名
		if(tab == 'username' && val){
			var res = /[\u4E00-\u9FA5]{2,5}(?:·[\u4E00-\u9FA5]{2,5})*/.test(val);
			html(obj,res,'真实姓名格式错误！');
		}
		//邮箱验证
		else if(tab == 'email' && val){
			var res = /^\w+(?:[-+.']\w+)*@\w+(?:[-.]\w+)*\.\w+(?:[-.]\w+)*$/.test(val);
			html(obj,res,'邮箱格式错误！');
		}else if(tab == 'password' && val){
			var res = /^[^\u4e00-\u9fa5\s]{6,20}$/.test(val);
			html(obj,res,'密码至少为6位！');
		}else if(tab == 's_password' && val){
			var val2 = $("input[name='password']").val();
			res = (val == val2) ? true : false;
			html(obj,res,'两次密码输入不一致！');
		}
	}

	//正则检测
	var html = function(obj,res,val){
		(res) ? $(obj).parent().parent().find(".info").removeClass("info_w").html("<p class='home'><svg  class='icon' aria-hidden='true'><use xlink:href='#icon-tongguo'></use></svg></p>") : $(obj).parent().parent().find(".info").addClass("info_w").html("<span>"+val+"</span>");
	}

	//登录验证
	function login(){
	    var params = $("form").serialize();
	    var act;
	    if("{{$smarty.get.act}}" == 'student_register')
	    	act = 'student';
	    else if("{{$smarty.get.act}}" == 'teacher_register')
	    	act = 'teacher';
	    $.post('{{"index.php?app=index&register"|URL}}',params,function(result){
	        if(result.statusCode=='200'){
	        	ui.success(result.message);
	        	setTimeout(function(){
					var url = "{{$smarty.const.__PROJECT__}}Index/"+act; 
					document.location.href = url;//登录后跳转页面
				},1000);
	        }else if(result.statusCode=='300'){
	        	$("input[name='"+result.message.name+"']").parent().parent().find(".info").addClass("info_w").html(result.message.message);
	        	$(".change_verify").trigger("click");
				$(".verity").val("");
	        }
	    },'json');
	};
	</script>
</html>